<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="jquery.min.js"></script>
</head>

<body>
    <script>
        let p = new Promise((resolve, reject) => {

            $.ajax({
                url: '/data.txt',
                dataType: 'json',
                success(success) {
                    resolve(success)
                },
                error(err) {
                    reject(err)
                }
            })

            // (resolve(success)) || (reject(err))
        }).then((success) => {
            alert('请求成功')
            success.forEach(element => {
                console.log(element);
            });
        }, err => {
            alert('请求错误')
        })
        
    </script>
</body>

</html>